package gui;

import common.EarthImage;

import simulation.initiatives.EnginePull;

/**
 * Use this thread for a pulling initiative (obviously)
 */
public class EarthGridThreadPull extends EarthGrid {
  private static final long serialVersionUID = 3239692731026301661L;
  private EnginePull engine;
  
  public EarthGridThreadPull(EarthImage earthImage) {
    super(earthImage);
  }
  
  public synchronized void updateGrid(EnginePull engine) {
    this.engine = engine;
    this.notify();
  }
  
  public void run() {
    Thread thisThread = Thread.currentThread();
    
    while(true) {
      try {
        thisThread.sleep(10);

        synchronized (this) {
          wait();
        }
      }
      catch (InterruptedException e) {
        e.printStackTrace();
      }
      super.updateGrid(engine);
    }
  }
  
}
